package com.feri.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.feri.api.dao.TypeDao;
import com.feri.api.service.intf.TypeService;
import com.feri.api.vo.R;
import com.feri.common.entity.Type;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @autor wfl
 * @time 2022/10/4
 */
@Service
public class TypeServiceImpl implements TypeService {
    @Resource
    private TypeDao dao;
    @Override
    public R save(String name) {
        Type type = new Type(name);
        if (type != null){
            dao.insert(type);
            return R.ok();
        }
        return R.fail();
    }

    @Override
    public R delete(long id) {
        if(id >0){
            dao.deleteById(id);
            return R.ok();
        }
        return R.fail();
    }

    @Override
    public R QueryList() {
        return R.ok(dao.selectList(null));
    }

    @Override
    public R update(Type type) {
        if(type !=null){
            dao.updateById(type);
            return R.ok();
        }else {
            return R.fail();
        }
    }
}
